$(function(){

    $('#switch_qlogin').click(function(){
        $('#switch_login').removeClass("switch_btn_focus").addClass('switch_btn');
        $('#switch_qlogin').removeClass("switch_btn").addClass('switch_btn_focus');
        $('#switch_bottom').animate({left:'0px',width:'70px'});
        $('#qlogin').css('display','none');
        $('#web_qr_login').css('display','block');

    });
    $('#switch_login').click(function(){

        $('#switch_login').removeClass("switch_btn").addClass('switch_btn_focus');
        $('#switch_qlogin').removeClass("switch_btn_focus").addClass('switch_btn');
        $('#switch_bottom').animate({left:'154px',width:'70px'});

        $('#qlogin').css('display','block');
        $('#web_qr_login').css('display','none');
    });
    if(getParam("a")=='0')
    {
        $('#switch_login').trigger('click');
    }

});

function logintab(){
    scrollTo(0);
    $('#switch_qlogin').removeClass("switch_btn_focus").addClass('switch_btn');
    $('#switch_login').removeClass("switch_btn").addClass('switch_btn_focus');
    $('#switch_bottom').animate({left:'154px',width:'96px'});
    $('#qlogin').css('display','none');
    $('#web_qr_login').css('display','block');

}


//鏍规嵁鍙傛暟鍚嶈幏寰楄鍙傛暟 pname绛変簬鎯宠鐨勫弬鏁板悕
function getParam(pname) {
    var params = location.search.substr(1); // 鑾峰彇鍙傛暟 骞充笖鍘绘帀锛�
    var ArrParam = params.split('&');
    if (ArrParam.length == 1) {
        //鍙湁涓€涓弬鏁扮殑鎯呭喌
        return params.split('=')[1];
    }
    else {
        //澶氫釜鍙傛暟鍙傛暟鐨勬儏鍐�
        for (var i = 0; i < ArrParam.length; i++) {
            if (ArrParam[i].split('=')[0] == pname) {
                return ArrParam[i].split('=')[1];
            }
        }
    }
}


var reMethod = "GET",
    pwdmin = 6;

$(document).ready(function() {


    $('#reg').click(function() {

        if ($('#user').val() == "") {
            $('#user').focus().css({
                border: "1px solid red",
                boxShadow: "0 0 2px red"
            });
            $('#userCue').html("<font color='red'><b>脳鐢ㄦ埛鍚嶄笉鑳戒负绌�</b></font>");
            return false;
        }



        if ($('#user').val().length < 4 || $('#user').val().length > 16) {

            $('#user').focus().css({
                border: "1px solid red",
                boxShadow: "0 0 2px red"
            });
            $('#userCue').html("<font color='red'><b>脳鐢ㄦ埛鍚嶄綅4-16瀛楃</b></font>");
            return false;

        }
        $.ajax({
            type: reMethod,
            url: "/member/ajaxyz.php",
            data: "uid=" + $("#user").val() + '&temp=' + new Date(),
            dataType: 'html',
            success: function(result) {

                if (result.length > 2) {
                    $('#user').focus().css({
                        border: "1px solid red",
                        boxShadow: "0 0 2px red"
                    });$("#userCue").html(result);
                    return false;
                } else {
                    $('#user').css({
                        border: "1px solid #D7D7D7",
                        boxShadow: "none"
                    });
                }

            }
        });


        if ($('#passwd').val().length < pwdmin) {
            $('#passwd').focus();
            $('#userCue').html("<font color='red'><b>脳瀵嗙爜涓嶈兘灏忎簬" + pwdmin + "浣�</b></font>");
            return false;
        }
        if ($('#passwd2').val() != $('#passwd').val()) {
            $('#passwd2').focus();
            $('#userCue').html("<font color='red'><b>脳涓ゆ瀵嗙爜涓嶄竴鑷达紒</b></font>");
            return false;
        }

        var sqq = /^[1-9]{1}[0-9]{4,9}$/;
        if (!sqq.test($('#qq').val()) || $('#qq').val().length < 5 || $('#qq').val().length > 12) {
            $('#qq').focus().css({
                border: "1px solid red",
                boxShadow: "0 0 2px red"
            });
            $('#userCue').html("<font color='red'><b>脳QQ鍙风爜鏍煎紡涓嶆纭�</b></font>");return false;
        } else {
            $('#qq').css({
                border: "1px solid #D7D7D7",
                boxShadow: "none"
            });

        }

        $('#regUser').submit();
    });


});